package com.example.administrator.appstpremvpdemo.binder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.administrator.appstpremvpdemo.R;

/**
 * @Author Administrator
 * @Date 2017/12/25
 * @description
 * @function    ViewBinder具体实现类，实现条目的展示（数据绑定控件），和事件的处理
 */

public class HomeListBinder extends BaseViewBinder implements BaseViewBinder.OnItemClickListener,View.OnClickListener{

    private TextView mTv;
    private ImageView mIv;

    public HomeListBinder(ViewGroup group, int layoutId) {
        super(group, layoutId);
    }

    @Override
    public void onViewInflate(View rootView) {
        mTv = ((TextView) rootView.findViewById(R.id.tv));
        mIv = ((ImageView) rootView.findViewById(R.id.iv));
    }

    @Override
    public void onbind(Object object) {
        mTv.setText(((String) object));
        mIv.setOnClickListener(this);
        setOnViewClickListener(this);
    }

    @Override
    public void OnItemClick(BaseViewBinder binder, View view) {
        Toast.makeText(mContext, "binder.getItemPostion():" + binder.getItemPostion(), Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.iv:
            Toast.makeText(mContext, "我是一张图片", Toast.LENGTH_SHORT).show();
            break;
        }
    }
}
